//
//  EqpInfoTabController.m
//  Hive
//
//  Created by 惠俊贝 on 15/9/3.
//  Copyright (c) 2015年 ZM. All rights reserved.
//

#import "EqpInfoTabController.h"
#import "CommonDefine.h"
#import "EqpInfoViewController.h"
#import "FollowViewController.h"
#import "PathViewController.h"
#import "EqpSetViewController.h"
#import "EqpInfo.h"
@interface EqpInfoTabController () {
    EqpInfoViewController *firstVC;
    
    FollowViewController *secondeVC;
    
    PathViewController *thirdVC;
    
    EqpSetViewController *forthVC;
}

@end

@implementation EqpInfoTabController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    firstVC = [[EqpInfoViewController alloc] initWithNibName:@"EqpInfoViewController" bundle:nil];
    
    firstVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"信息" image:[UIImage imageNamed:@"tab_msg_normal"] tag:100];
    
    secondeVC = [[FollowViewController alloc] init];
    
    secondeVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"追踪" image:[UIImage imageNamed:@"tab_track_normal"] tag:200];
    
    thirdVC = [[PathViewController alloc] init];
    
    thirdVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"轨迹回放" image:[UIImage imageNamed:@"tab_history_normal"] tag:300];
    thirdVC.tabBarItem.enabled = NO;
    
    forthVC = [[EqpSetViewController alloc] initWithNibName:@"EqpSetViewController" bundle:nil];
    
    forthVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"设置" image:[UIImage imageNamed:@"tab_set_normal"] tag:400];
    
    [self.tabBar setBackgroundColor:[UIColor grayColor]];
    [self setViewControllers:@[firstVC, secondeVC, thirdVC, forthVC]];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
//    [self setupCustomNavgationBar];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma setter
- (void)setEqpInfo:(EqpInfo *)eqpInfo {
    _eqpInfo = eqpInfo;
    firstVC.eqpInfo = self.eqpInfo;
    secondeVC.eqpInfo = self.eqpInfo;
    thirdVC.eqpInfo = self.eqpInfo;
    forthVC.eqpInfo = self.eqpInfo;
    
}



- (void)backButtonPress:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)menuButtonPress:(id)sender {
    
}

#pragma mark - private method
- (void)setupCustomNavgationBar {
    
    CGRect frame = CGRectMake(0, 0, SCREEN_WIDTH, 44+STATUS_BAR_HEIGHT);
    UIView *backView= [[UIView alloc]initWithFrame:frame];
    
    UIView *colorView= [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44+STATUS_BAR_HEIGHT)];
    colorView.backgroundColor=kThemeOrangeColor;
    [backView addSubview:colorView];
    
    
    //添加标题
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH -200)/2, 11+STATUS_BAR_HEIGHT, 200, 24)];
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    label.font=[UIFont fontWithName:@"MicrosoftYaHei" size:20.0];
    NSString *eqpName = self.eqpInfo.EqpName == nil ? @"":self.eqpInfo.EqpName;
    label.text = eqpName;
    [label setShadowColor:[UIColor darkGrayColor]];
    //        [label setShadowOffset:CGSizeMake(0, -0.5)];
    [backView addSubview:label];
    
    //添加返回按钮
    backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setFrame:CGRectMake(0, 0+STATUS_BAR_HEIGHT, 44, 44)];
    [backButton setImage:[UIImage imageNamed:@"backButton.png"] forState:UIControlStateNormal];
    //    UIBarButtonItem *searchButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    [backButton addTarget:self action:@selector(backButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:backButton];
    
    //添加菜单按钮
    menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menuButton setFrame:CGRectMake(SCREEN_WIDTH-50, 0+STATUS_BAR_HEIGHT, 64, 44)];
    [menuButton setImage:[UIImage imageNamed:@"learnMenu.png"] forState:UIControlStateNormal];
    [menuButton setImage:[UIImage imageNamed:@"learnMenuHighlight.png"] forState:UIControlStateHighlighted];
    //    UIBarButtonItem *searchButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    [menuButton addTarget:self action:@selector(menuButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [menuButton setHidden:YES];
    [backView addSubview:menuButton];
    
    [self.view addSubview:backView];
}

@end
